package com.action.blog.board;

import java.util.Map;

import com.db.blogboard.*;
import com.opensymphony.xwork2.ActionContext;

public class DeleteOkAction {

	private int jsptype;
	private String page;
	private int ono;
	private int no;
	private String pwd;
	private String result;
	private BoardDAO blogboard;

	public BoardDAO getBlogboard() {
		return blogboard;
	}

	public void setBlogboard(BoardDAO blogboard) {
		this.blogboard = blogboard;
	}

	public String getPage() {
		return page;
	}

	public void setPage(String page) {
		this.page = page;
	}

	public int getJsptype() {
		return jsptype;
	}

	public void setJsptype(int jsptype) {
		this.jsptype = jsptype;
	}

	public int getOno() {
		return ono;
	}

	public void setOno(int ono) {
		this.ono = ono;
	}

	public String getResult() {
		return result;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	public int getNo() {
		return no;
	}

	public void setNo(int no) {
		this.no = no;
	}

	public String bbdelete_ok() throws Exception {
		BoardVO vo = new BoardVO();

		Map session = ActionContext.getContext().getSession();
		vo.setOno(ono);
		vo.setIdtype(session.get("idtype").toString());
		vo.setNo(no);
		vo = blogboard.boardSelectContentData(vo);

		if (vo.getPwd().equals(pwd)) {
			result = "OK";
			blogboard.bbdelete(no);
		} else {
			result = "NO";
		}

		return "success";
	}

	public String bpdelete_ok() throws Exception {
		BoardVO vo = new BoardVO();

		Map session = ActionContext.getContext().getSession();
		vo.setOno(ono);
		vo.setIdtype(session.get("idtype").toString());
		vo.setNo(no);
		vo = blogboard.boardSelectContentData(vo);

		if (vo.getPwd().equals(pwd)) {
			result = "OK";
			blogboard.bbdelete(no);
		} else {
			result = "NO";
		}

		return "success";
	}
}
